{extend name="layout:base" /}

{block name="content"}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <form id="form1" class="layui-form">
                <div class="layui-row layui-col-space10 layui-form-item">
                    <div class="layui-col-lg12">
                        <label class="layui-form-label">旧密码：</label>
                        <div class="layui-input-block">
                            <input type="password" name="oldPassword" lay-verify="required" lay-verType="tips" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-row layui-col-space10 layui-form-item">
                    <div class="layui-col-lg12">
                        <label class="layui-form-label">新密码：</label>
                        <div class="layui-input-block">
                            <input type="password" name="password" lay-verify="pass" lay-verType="tips" autocomplete="off" id="LAY_password" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-row layui-col-space10 layui-form-item">
                    <div class="layui-col-lg12">
                        <label class="layui-form-label">确认密码：</label>
                        <div class="layui-input-block">
                            <input type="password" name="repassword" lay-verify="repass" lay-verType="tips" autocomplete="off" class="layui-input">

                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="btnSave">保存</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

{/block}


{block name="script"}
<script type="text/javascript">
    layui.config({
        base: '__STATIC__/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','layer','set', 'form'], function () {
        var $ = layui.$, form = layui.form;

        form.on('submit(btnSave)', function (data) {
            $.post("{:url('/admin/Index/change_pwd')}", data.field, function (result) {
                if (result['code'] == 0) {
                    layer.msg(result['msg'], {icon: 1, time: 1000}, function () {
                        location.reload();
                    });
                } else {
                    layer.msg(result['msg'], {icon: 3, time: 3000});
                }
            });
            return false;
        });
    });
</script>
{/block}